﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using KingRoad.EPM.SafetyManagementBLL.Domain;
using KingRoad.EPM.SafetyManagementEntity.Model;
using Unis.Framework.Core.Utility;
using KingRoad.EPM.SafetyManagementDAL.ScmSafetyconstructiondicService;
using System.Data;


namespace KingRoad.EPM.SafetyManagementBLL.UIRules
{
    /// <summary> 
    /// 客户端业务处理类。 
    /// 文件生成时间 2017/1/12 14:00:08
    /// </summary> 
    public class ScmSafetyconstructiondicUIRule
    {
        private readonly IScmSafetyconstructiondicService _scmSafetyconstructiondicService;


        public ScmSafetyconstructiondicUIRule() { }

        /// <summary> 
        /// construct function... 
        /// </summary> 
        public ScmSafetyconstructiondicUIRule(IScmSafetyconstructiondicService scmSafetyconstructiondicService)
        {
            _scmSafetyconstructiondicService = scmSafetyconstructiondicService;
        }

        /// <summary>
        /// 获取所有数据字典
        /// </summary>
        /// <returns></returns>
        public List<ScmSafetyconstructiondicInfo> GetAllSafetyconstructiondic()
        {
            var list = _scmSafetyconstructiondicService.GetEntityList();
            return list;
        }
        /// <summary>
        /// 根据ID获取数据字典
        /// </summary>
        /// <param name="parentID">ID</param>
        /// <returns></returns>
        public ScmSafetyconstructiondicInfo GetSafetyconstructiondicByID(Guid ID)
        {
            var list = _scmSafetyconstructiondicService.GetEntityById(ID);
            return list;
        }
        /// <summary>
        /// 根据父类型ID获取数据字典
        /// </summary>
        /// <param name="parentID">父类型ID</param>
        /// <returns></returns>
        public List<ScmSafetyconstructiondicInfo> GetSafetyconstructiondicByPID(string parentID)
        {
            string sql = " 1=1 ";
            if (parentID != "")
                sql = "Scd_ParentID='" + parentID + "'";
            var list = _scmSafetyconstructiondicService.GetEntityList(sql);
            return list;
        }
        
            /// <summary>
        /// 根据父类型ID获取所有职位
        /// </summary>
        /// <param name="parentID">父类型ID</param>
        /// <returns></returns>
        public DataTable GetSafetyconstructiondicByPIDs(string parentIDs)
        {
            string sql = " 1=1 ";
            if (parentIDs != "")
                sql = "Scd_ParentID in (" + parentIDs + ")";
            var dt = _scmSafetyconstructiondicService.GetSafetyconstructiondicByPIDs(sql);
            return dt;
        }
        /// <summary>
        /// 根据条件查询字典信息(分页)
        /// </summary>
        /// <param name="numCurrentPage">当前页</param>
        /// <param name="numPerPage">每页数据大小</param>
        /// <param name="orderByField">排序字段名称</param>
        /// <param name="totalRecord">总数据量</param>
        /// <param name="sqlCondition">sql查询条件</param>
        /// <returns></returns>
        public List<ScmSafetyconstructiondicInfo> GetSafetyconstructiondicForPage(int numCurrentPage, int numPerPage,
                                                                        string orderByField, out int totalRecord, string sqlCondition)
        {
            var list = _scmSafetyconstructiondicService.GetEntityListByContionRe(numCurrentPage, numPerPage, orderByField, out totalRecord, sqlCondition);
            return list;
        }
        /// <summary>
        /// 添加
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public bool InsertEntity(ScmSafetyconstructiondicInfo entity)
        {
            var ret = _scmSafetyconstructiondicService.InsertEntity(entity);
            return ret > 0;
        }
        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public bool UpdateEntity(ScmSafetyconstructiondicInfo entity)
        {
            var ret = _scmSafetyconstructiondicService.UpdateEntity(entity);
            return ret > 0;
        }
        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public bool DeleteEntity(string id)
        {
            var ret = _scmSafetyconstructiondicService.DeleteEntityByStringID(id);
            return ret > 0;
        }
        /// <summary>
        /// 批量删除
        /// </summary>
        /// <param name="ids"></param>
        /// <returns></returns>
        public bool DeleteEntityByMultiStringID(string ids)
        {
            var ret = 0;
            foreach (string id in ids.Split(','))
            {
                ret = _scmSafetyconstructiondicService.DeleteEntityByStringID(id);
            }
            return ret > 0;
        }
    }
}
